/*
 * vid_to_pic.cpp
 * 视频转图片模块
 * 功能：将视频文件转换为图片序列
 * 使用 FFmpeg 工具，每秒提取一帧
 * 输出：在 Scrimage 目录下生成图片序列
 */

#pragma once
#include <string>
#include <iostream>
#include <filesystem>
#include <cstdlib>
#include "vid_to_pic.h"
#include <opencv2/opencv.hpp>
#include <direct.h>

using namespace std;

void vtop(const std::string& videoPath)
{
        const std::string outputDir = "Scrimage";
  
    std::filesystem::create_directories(outputDir);

    std::string ffmpegCmd = "ffmpeg -i \"" + videoPath + "\" -r 1 \"" + outputDir + "/image_%03d.JPG\"";

    int result = std::system(ffmpegCmd.c_str());

    if (result == 0) {
        std::cout << "Successful" << std::endl;
    }
    else {
        std::cout << "Error" << std::endl;
    }
}
